package com.zhanghu.backendZray.controller.dailyPlan;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhanghu.backendZray.annotation.MenuNeed;
import com.zhanghu.backendZray.pojo.dto.ApiResponse;
import com.zhanghu.backendZray.pojo.request.dailyPlanTask.DailyTaskPageRequest;
import com.zhanghu.backendZray.pojo.request.OnlyIdRequest;
import com.zhanghu.backendZray.pojo.vo.DailyTaskVo;
import com.zhanghu.backendZray.service.DailyTaskService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 每日任务
 * @author ZhangDong
 * @date 2024/7/10 17:30
 */
@RestController
@RequestMapping("dailyTask")
@AllArgsConstructor
public class DailyTaskController {

    private final DailyTaskService dailyTaskService;
    /**
     * 查询每日任务列表
     */
    @MenuNeed(menuName = "task_list")
    @PostMapping("page")
    public ApiResponse<Page<DailyTaskVo>> page(@RequestBody DailyTaskPageRequest request) {
        Page<DailyTaskVo> pageInfo = dailyTaskService.page(request);
        return ApiResponse.ok(pageInfo);
    }

    /**
     * 完成任务
     */
    @MenuNeed(menuName = "task_list")
    @PostMapping("finishTask")
    public ApiResponse finishTask(@RequestBody OnlyIdRequest request) {
        dailyTaskService.finishTask(request);
        return ApiResponse.ok();
    }
}
